import instance from './index';
import qs from 'qs';

const preUrlPath = '';
//获取系统业务配置列表
const request = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/cfg/fetchConfigList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取系统配置类型列表
const requestConfig = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/cfg/fetchConfigType`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取交易区域列表
const requestList = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/cfg/fetchTransAreaList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};

//编辑参数配置
const modify = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/cfg/modify`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};

//设置币种状态
const setStatus = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/coin/setCoinStatus`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//添加系统配置
const add = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/v1/cfg/new`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取币种信息
const info = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/coin/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};

//删除用户
const remove = {
  p: ['api:user:delete'],
  r: params => {
    return instance.delete(`/user/del/${params.id}`)
  }
};

//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(`${preUrlPath}/GET/roles/notAllowed`, {params})
  }
}

export {
  request,
  remove,
  notAllowed,
  add,
  modify,
  info,
  setStatus,
  requestConfig,

}
